﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOABLL;
using TarreOA.TarreOAModels;

public partial class leaderManager_ShowEvectionInfo : System.Web.UI.Page
{
    static List<EvectionInfo> list = null;
    static EvectionInfo evectionInfoBlur = new EvectionInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Session["ShowMessage"] = "用户未登录，请重新登录!";
            Session["Backurl"] = "Login.aspx";
            Response.Redirect("~/Message.aspx");
        }
        else
        {
            TarreOA.TarreOAModels.User sucessUser = (User)Session["user"];
            bool userFlag = false;
            if (sucessUser.PopedomGroup.PopedomList != null)
            {
                foreach (Popedom var in sucessUser.PopedomGroup.PopedomList)
                {
                    if (var.PopedomId == 87)
                    {
                        userFlag = true;
                        break;
                    }
                }
            }
            if (!userFlag)
            {
                Session["ShowMessage"] = "用户没有该权限，请与管理员联系!";
                Session["Backurl"] = "Right.aspx";
                Response.Redirect("~/Message.aspx");
            }
        }
        if (!IsPostBack)
        {
            list = EvectionInfoManager.FindBlurEvectionInfo(new EvectionInfo());
            GridView1.DataSource = list;
            GridView1.DataBind();
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = list;
        GridView1.DataBind();
    }
    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        evectionInfoBlur = new EvectionInfo();
        evectionInfoBlur.IsBack = Convert.ToInt32(ddlIsBack.SelectedValue);
        if (txtEvectionUser.Text !="" && hidUserId.Value!="")
        {
            TarreOA.TarreOAModels.User user = new User();
            user.UserId = Convert.ToInt32(hidUserId.Value);
            evectionInfoBlur.EvectionUser = user;
        }
        if (txtBeginDate.Text != "")
        {
            evectionInfoBlur.BeginDate = Convert.ToDateTime(txtBeginDate.Text);
        }
        if (txtEndDate.Text != "")
        {
            evectionInfoBlur.EndDate = Convert.ToDateTime(txtEndDate.Text);
        }
        list = EvectionInfoManager.FindBlurEvectionInfo(evectionInfoBlur);
        GridView1.DataSource = list;
        GridView1.DataBind();
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "showInfo")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "window.showModalDialog ('../admin/ShowInfo.aspx?id=" + e.CommandArgument.ToString() + "&type=3', '','status:no;center:yes;scroll:no;resizable:no;help:no;dialogWidth:550px;dialogHeight:400px');", true);
        }
        else if (e.CommandName=="updateState")
        {
            if (EvectionInfoManager.UpdateState(Convert.ToInt32(e.CommandArgument)))
            {
                int pageIndex = GridView1.PageIndex;
                list = EvectionInfoManager.FindBlurEvectionInfo(evectionInfoBlur);
                GridView1.DataSource = list;
                GridView1.PageIndex = pageIndex;
                GridView1.DataBind();
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('编辑失败！请重试！')", true);
            }
        }
    }
}
